//2009/09/09 09:01:00
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class TandemRepeats
{
public:
    int maxLength(string dna, int k)
    {
        int mmax = 0;
        for (int len = 1; len <= dna.size()/2; len++)
            for (int i = 0; i+2*len-1 < dna.size(); i++)
            {
                string s1 = dna.substr(i, len);
                string s2 = dna.substr(i+len, len);
                int dif = 0;
                for (int k=0; k<len; k++)
                    if (s1[k]!=s2[k])
                        dif++;
                if (dif <= k) mmax = len;
            }
        return mmax;
    }
};
